package lt.ntec.danblog.server.core.model.gae;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
class JDORelationMap {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;
    @Persistent
    private String fullClassName;
    @Persistent
    private Key key;

    public JDORelationMap(String fullClassName, Key key) {
        super();
        this.fullClassName = fullClassName;
        this.key = key;
    }

    public String getFullClassName() {
        return fullClassName;
    }

    public Key getKey() {
        return key;
    }

    @Override
    public int hashCode() {
        return getFullClassName().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof JDORelationMap)) {
            return false;
        }
        JDORelationMap m = (JDORelationMap) o;
        if (m.getFullClassName().equals(getFullClassName())
                && m.getKey().equals(getKey())) {
            return true;
        }
        return false;
    }
}
